<!DOCTYPE html>
<html lang="zh">
<head>
    <title>简易逻辑</title>
    <{include file="draw_logic/public/header"}>
    <{include file="draw_logic/public/data_tables_css"}>

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <{include file="draw_logic/public/navbar"}>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <!--左侧菜单-->
    <{include file="draw_logic/public/sidebar"}>

    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>逻辑管理</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="<{:url('index')}>">首页</a></li>
                            <li class="breadcrumb-item active">逻辑列表</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">


                <div class="card">
                    <div class="card-header">
                        <form action="<{:url()}>">
                            <div class="form-row ">
                                <div class="col-auto">

                                    <input name="keyword" type="text" class="form-control " placeholder="名称" value="">
                                </div>

                                <div class="col-auto">
                                    <button type="submit" class="btn btn-primary mb-2 "><i class="fas fa-search"></i></button>
                                </div>
                            </div>
                        </form>
                        <a href="<{:url('form')}>" class="btn btn-success">新增</a>
                    </div>


                    <div class="card-body">

                        <table id="my_table" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>key</th>
                                <th>名称</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <{if !empty($data)}>
                            <{foreach $data as $item}>
                            <tr>
                                <td><{$item.id}></td>
                                <td><{$item.key}></td>
                                <td>
                                    <a href="<{:url('/plugin/draw_logic.client/detail')}>?key=<{$item.key}>" target="_blank">
                                    <{$item.title}>
                                </a>
                                </td>

                                <td>
                                    <a class="btn btn-success btn-xs" href="<{:url('form',['key'=>$item.key])}>" title="查看编辑"><i class="fas fa-edit"></i></a>
                                    <span class="btn btn-danger btn-xs del-data bs-left-10" onclick="del(this)" data-key="<{$item.key}>" title="删除"><i class="fas fa-trash"></i></span>
                                    <span class="btn  btn-default btn-xs set-status bs-left-10" onclick="set_copy(this)"  data-key="<{$item.key}>"   title="复制一份"><i class="fas fa-copy"></i></span>
                                </td>

                            </tr>
                            <{/foreach}>
                            <{/if}>



                            </tbody>

                        </table>
                    </div>
                    <div class="card-footer">
                        <{$page?$page->render():''}>
                    </div>
                    <!-- /.card-body -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>


</div>
<!-- ./wrapper -->

<{include file="draw_logic/public/footer"}>
<!-- DataTables  & Plugins -->
<{include file="draw_logic/public/data_tables"}>
<script>
    $(function () {
        $("#my_table").DataTable({
            "ordering": false,//禁用排序
            "responsive": true,
            "lengthChange": false,
            "autoWidth": false,
            //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
            // "pageLength": 10,         //初始化显示几条数据
            //serverSide: true, // use local process instead of server
            bFilter: false, // show top right search input box.
            bPaginate: false,//是否开启分页
            iDisplayLength: 10, //默认显示的记录数
            bInfo: false,//是否显示页脚信息，DataTables插件左下角显示记录数
        }).buttons().container().appendTo('#my_table_wrapper .col-md-6:eq(0)');

    });

    function set_copy(obj){
        var key = $(obj).data('key');
        layer.confirm('确定复制？',{title:'复制确认',btn:['确定','点错了']},function (index) {
            sendData("<{:url('action')}>",{key:key,ac:'copy'},function (res) {
                if (res.code==0){
                    location.reload()
                }
            })

        })
    }
</script>
<script>


    function del(obj){
        var key = $(obj).data('key');
        layer.confirm('确定要删除吗',{title:'操作确认',btn:['确定','点错了']},function (index) {
            sendData("<{:url('action')}>",{key:key,ac:'del'},function (res) {
                if (res.code==0){
                    $(obj).parent('td').parent('tr').remove()
                    layer.close(index)
                }
            })

        })
    }



</script>
</body>
</html>
